<?php
/**
 * Created by PhpStorm.
 * User: syzhou
 * Date: 2019-10-16
 * Time: 15:01
 */

namespace App\Http\Controllers;


use App\ReviewerGroupProject;
use App\Services\ProjectService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;

class MeetingReviewAPIController extends Controller
{

    public function getProjects(){
        $user = Request::user();
        //查询大组
        $groupInfo = DB::table('meeting_review_reviewers')->where('reviewer_id',$user->id)->first();
        $largeGroupId = (int) $groupInfo->large_group_id;
        $result = (new ProjectService())->leaderGetMeetingReviewProjects($largeGroupId);
        foreach ($result['projects'] as $project) {
            $project->avg_score = null;
            $project->score_per_reviewer = [];
            $project->scores_desc = null;
        }
//        usort($result['projects'], function($a, $b) {
//            return $a->project_id - $b->project_id;
//        });
        return $this->json($result);
    }

}
